home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWGraphx / Include / FWBitmap.h < prev    next >
Encoding:
Text File  |  1996-04-25  |  5.6 KB  |  217 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWBitmap.h
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWBITMAP_H
  11. #define FWBITMAP_H
  12.  
  13. #ifndef FWGCONST_H
  14. #include "FWGConst.h"
  15. #endif
  16.  
  17. #ifndef FWRECT_H
  18. #include "FWRect.h"
  19. #endif
  20.  
  21. #ifndef SLGRDEF_H
  22. #include "SLGrDef.h"
  23. #endif
  24.  
  25. #ifndef SLGDEV_H
  26. #include "SLGDev.h"
  27. #endif
  28.  
  29. #ifndef FWRESOUR_H
  30. #include "FWResour.h"
  31. #endif
  32.  
  33. #ifndef FWGC_H
  34. #include "FWGC.h"
  35. #endif
  36.  
  37. #ifndef FWPICTUR_H
  38. #include "FWPictur.h"
  39. #endif
  40.  
  41. #ifndef SLBITMAP_H
  42. #include "SLBitmap.h"
  43. #endif
  44.  
  45. #ifndef SLPALETE_H
  46. #include "SLPalete.h"
  47. #endif
  48.  
  49. //========================================================================================
  50. //    Forward Class Declarations
  51. //========================================================================================
  52.  
  53. class    FW_CWritableStream;
  54. class    FW_CReadableStream;
  55. class    FW_CPicture;
  56. class    FW_CGraphicContext;
  57. struct    FW_SGraphicContext;
  58. class    FW_CColor;
  59. struct    FW_SColor;
  60.  
  61. //========================================================================================
  62. //    class FW_CBitmap
  63. //========================================================================================
  64.  
  65. class FW_CBitmap : public FW_TGrRefPtr<FW_HBitmap>
  66. {
  67. public:
  68.     FW_DECLARE_AUTO(FW_CBitmap)
  69.  
  70.     FW_CBitmap();
  71.     ~FW_CBitmap();
  72.     
  73.     FW_CBitmap(short width, short height,
  74.         short pixelSize, FW_Palette palette = NULL);
  75.         
  76.     FW_CBitmap(void* image, long imageSize, short rowBytes,
  77.         short width, short height, short pixelSize, FW_Palette palette = NULL);
  78.  
  79. #ifdef FW_BUILD_MAC
  80.     static const FW_SRect gWholePicture;
  81.     FW_CBitmap(const FW_CPicture& picture,
  82.               const FW_CColor& fillColor = FW_kRGBWhite,
  83.               const FW_CRect& pictPart = gWholePicture);
  84.               
  85.     FW_CPicture MacGetAsPicture(const FW_SRect& pictPart = gWholePicture) const;
  86. #endif
  87.  
  88.     FW_CBitmap(FW_PResourceFile& resourceFile, FW_ResourceId resId);
  89.     FW_CBitmap(FW_CReadableStream& stream, FW_Boolean bDIBHeader = TRUE);
  90.  
  91.     FW_CBitmap(FW_PlatformBitmap platformBitmap);
  92.     
  93.     FW_CBitmap(const FW_CBitmap& other);
  94.     FW_CBitmap& operator=(const FW_CBitmap& other);
  95.     
  96.     FW_CBitmap    Copy(const FW_CRect& srcRect) const;
  97.     
  98.     friend FW_CReadableStream& operator>>(FW_CReadableStream& stream, FW_CBitmap& bitmap);
  99.     friend FW_CWritableStream& operator<<(FW_CWritableStream& stream, const FW_CBitmap& bitmap);
  100.  
  101.     // Delegation
  102.     
  103.     FW_Boolean             IsEqual(const FW_CBitmap& bitmap) const
  104.         { return FW_PrivBitmap_IsEqual(fRep, bitmap.fRep); }
  105.  
  106.     // Handle operations
  107.     
  108.     FW_PlatformBitmap    GetPlatformBitmap() const
  109.         { return FW_PrivBitmap_GetPlatformBitmap(fRep); }
  110.         
  111.     FW_Boolean            IsPlatformBitmapOrphan() const
  112.         { return FW_PrivBitmap_IsPlatformBitmapOrphan(fRep); }
  113.         
  114.     FW_PlatformBitmap    OrphanPlatformBitmap() const
  115.         { return FW_PrivBitmap_OrphanPlatformBitmap(fRep); }
  116.         
  117.     void                 SetPlatformBitmap(FW_PlatformBitmap newBitmap)
  118.         { FW_PrivBitmap_SetPlatformBitmap(fRep, newBitmap); }
  119.         
  120.     void                AdoptPlatformBitmap(FW_PlatformBitmap newBitmap)
  121.         { FW_PrivBitmap_AdoptPlatformBitmap(fRep, newBitmap); }
  122.  
  123.     // Palette
  124.         
  125.     FW_Palette            GetPalette() const;
  126.         
  127.     void                SetPalette(FW_Palette palette)
  128.         { FW_FailOnError(FW_PrivBitmap_SetPalette(fRep, palette)); }
  129.  
  130.     // Bitmap info
  131.     void                GetBitmapInfo(
  132.                             short&        width,
  133.                             short&        height, 
  134.                             short&        rowBytes,
  135.                             short&        pixelSize) const
  136.         { FW_FailOnError(FW_PrivBitmap_GetBitmapInfo(fRep, width, height, rowBytes, pixelSize)); }
  137.  
  138.     void                GetBitmapBounds(FW_SGraphicContext& gc, FW_SRect& bounds) const;
  139.         
  140.     void                GetBitmapBounds(FW_SRect& bounds) const
  141.         { FW_PrivBitmap_GetBitmapBounds(fRep, bounds); }
  142.  
  143.     // Changing the bitmap
  144.     
  145.     void                ChangeBitmap(
  146.                             void*        image,
  147.                             long        imageSize,
  148.                             short        rowBytes,
  149.                             short        width,
  150.                             short        height, 
  151.                             short        pixelSize,
  152.                             FW_Boolean    bScale)
  153.         { FW_FailOnError(FW_PrivBitmap_ChangeBitmap(fRep, image, imageSize, rowBytes, width, height, pixelSize, bScale)); }
  154.                                     
  155.     void                ChangeBitmap(
  156.                             short        width,
  157.                             short        height, 
  158.                             short        pixelSize,
  159.                             FW_Boolean    bScale)
  160.         { FW_FailOnError(FW_PrivBitmap_ChangeBitmapGeometry(fRep, width, height, pixelSize, bScale)); }
  161.                                     
  162.     void                SetImage(void* image, long imageSize, short rowBytes)
  163.         { FW_FailOnError(FW_PrivBitmap_SetImage(fRep, image, imageSize, rowBytes)); }
  164.  
  165.     // Copy Pixels
  166.     void                CopyPixels(
  167.                             const FW_CBitmap&    bitmapDst,
  168.                             FW_SRect&             boundsSrc, 
  169.                             FW_SRect&            boundsDst)
  170.         { FW_FailOnError(FW_PrivBitmap_CopyPixels(fRep, bitmapDst.fRep, boundsSrc, boundsDst)); }
  171.  
  172.     // Macintosh specific
  173.     
  174. #ifdef FW_BUILD_MAC
  175.     
  176.     // Conversion
  177.     
  178.                         FW_CBitmap(
  179.                             FW_HPicture picture, FW_SColor fillColor,
  180.                             const FW_SRect& pictPart);
  181.     
  182.     PixMapHandle        MacLockPixels()
  183.         { return FW_PrivBitmap_MacLockPixels(fRep); }    // return NULL if fails
  184.         
  185.     void                MacUnlockPixels()
  186.         { FW_FailOnError(FW_PrivBitmap_MacUnlockPixels(fRep)); }
  187.         
  188.     FW_Boolean            MacIsPixelsLocked() const
  189.         { return FW_PrivBitmap_MacIsPixelsLocked(fRep); }
  190. #endif
  191. };
  192.  
  193. //========================================================================================
  194. //    class FW_CBitmapContext
  195. //========================================================================================
  196.  
  197. class FW_CBitmapContext : public FW_CGraphicContext
  198. {
  199. public:
  200.     FW_DECLARE_AUTO(FW_CBitmapContext)
  201.  
  202.     FW_CBitmapContext(Environment* ev, FW_CBitmap& bitmap);
  203.     ~FW_CBitmapContext();
  204.  
  205.     virtual void        Reset();
  206.     
  207. private:
  208.     FW_CBitmap             fBitmap;
  209.     FW_HGDevice            fGraphicDevice;
  210.     
  211. #ifdef FW_BUILD_WIN
  212.     HBITMAP                fOldBitmap;
  213. #endif
  214. };
  215.  
  216. #endif
  217.